#!ipxe

# Fedora Operating System
# https://getfedora.org/

isset ${dhcp-server} && set ipparam ip=dhcp || set ipparam ip=${ip}::${gateway}:${netmask}:::none nameserver=${dns}
set ipparam BOOTIF=${netX/mac} ${ipparam}

goto ${menu} ||

:fedora
clear osversion
clear sku_type
clear ova
clear bt
set os {{ releases.fedora.name }}
set os_arch ${arch}
iseq ${os_arch} x86_64 && set os_arch x86_64 ||
iseq ${os_arch} arm64 && set os_arch aarch64 ||

menu ${os} - ${os_arch}
item --gap Latest Releases
{% for item in releases.fedora.versions %}
item {{ item.code_name }} ${space} ${os} {{ item.name }}
{% endfor %}
iseq ${os_arch} x86_64 && item rawhide ${space} ${os} rawhide ||
isset ${osversion} || choose osversion || goto linux_menu
set ova ${os} ${osversion}
goto product_sku

:product_sku
menu ${os} ${os_arch} sku type
item Everything ${ova} Everything
item Server ${ova} Server
item Kinoite ${ova} Kinoite
item Onyx ${ova} Onyx
item Silverblue ${ova} Silverblue 
item Sericea ${ova} Sericea
isset ${sku_type} || choose sku_type || goto fedora
set dir ${fedora_base_dir}/releases/${osversion}/${sku_type}/${os_arch}/os
iseq ${osversion} rawhide && set dir ${fedora_base_dir}/development/${osversion}/${sku_type}/${os_arch}/os ||
set ova ${ova} ${sku_type}
echo ${cls}
goto boottype

:boottype
menu ${os} ${os_arch} boot type
item graphical ${ova} graphical install
item text ${ova} text install
item rescue ${ova} rescue
item kickstart ${ova} set kickstart url [ ${ks_url} ]
isset ${bt} || choose bt || goto fedora
echo ${cls}
iseq ${bt} normal && goto boot ||
goto ${bt}

:graphical
set install_mode inst.graphical ||
goto bootos_images

:text
set install_mode inst.text ||
goto bootos_images

:rescue
set params inst.rescue ||
goto bootos_images

:kickstart
echo -n Specify kickstart URL for ${os} ${osversion}: && read ks_url
set params inst.ks=${ks_url} ||
clear bt
goto boottype

:bootos_images
imgfree
kernel ${fedora_mirror}/${dir}/images/pxeboot/vmlinuz inst.repo=${fedora_mirror}/${dir} ${install_mode} ${params} ${ipparam} {{ kernel_params }}
initrd ${fedora_mirror}/${dir}/images/pxeboot/initrd.img
echo
echo MD5sums:
md5sum vmlinuz initrd.img
boot
goto linux_menu

:linux_menu
clear menu
exit 0
